import React, { Component } from 'react';
import { connect } from 'react-redux'
import { Modal, Form, Input, Select, Table, InputNumber, DatePicker, Popconfirm, Radio, Row, Col, } from 'antd';
import moment from 'moment'
const RadioGroup = Radio.Group;
const FormItem = Form.Item;
const Option = Select.Option;

class EditTimeModal extends Component {
    constructor(props) {
        super(props);
        this.state = {
            visible: false,
        };
    }

    okHandler = () => {
        const { onOk } = this.props;
        this.props.form.validateFields((err, values) => {
            if (!err) {
                onOk(values);
            }
        });
    };
    render() {
        const { children, dispatch, title, item } = this.props;
        console.log(item);
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: { span: 6 },
            wrapperCol: { span: 14 },
        };

        return (
            <span>
                <Modal
                    maskClosable={this.props.maskClosable}
                    confirmLoading={this.props.confirmLoading}
                    zIndex={200}
                    title={this.props.title + '\t' + '(资产编号:' + item.assetNo + '\t' + '资产序列号：' + item.serialNo + ')'}
                    visible={this.props.visible}
                    onOk={this.okHandler}
                    onCancel={this.props.onCancel}
                    key={this.props.newKey}
                >
                     <Form layout='horizontal' onSubmit={this.okHandler}>
                            <FormItem style={{ marginBottom: '0px' }}>
                                {getFieldDecorator('detailId', { initialValue: item.id_ })(
                                    <Input type="hidden" />
                                )}
                            </FormItem>
                            
                            <FormItem
                                label="入库时间"
                                {...formItemLayout}
                                hasFeedback
                            >
                                {getFieldDecorator('instockTime', {
                                    initialValue: item.instockTime?new moment(item.instockTime).format("YYYY-MM-DD HH:mm"):"",
                                    rules: [{
                                        required: true, type: 'object', whitespace: true, message: '请选择入库时间',
                                    }]
                                })(
                                    <DatePicker format="YYYY-MM-DD HH:mm" style={{ width: 270 }} />
                                    )}
                            </FormItem>
                            <FormItem
                                label="入库备注"
                                {...formItemLayout}
                                hasFeedback
                            >
                                {
                                    getFieldDecorator('desc', {
                                        initialValue: item.desc,
                                        rules: [{ max: 100, message: '备注信息 100 字符以内' },]
                                    })(<Input type="textarea" autosize={{ minRows: 4, maxRows: 4 }} />)
                                }
                            </FormItem>
                            
                        </Form>
                </Modal>

            </span>
        );
    }

}

export default Form.create()(EditTimeModal)
